﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MemberUser/MemberMaster.Master" AutoEventWireup="true" CodeBehind="MyOrder.aspx.cs" Inherits="ZLCMS.Web.MemberUser.MyOrder" EnableViewState="False" %>

<%@ Import Namespace ="ZLCMS.Business.Util" %>
<%@ Register src="UC/MemberCategory.ascx" tagname="MemberCategory" tagprefix="uc1" %>
<%@ Register src="UC/Ad_Right.ascx" tagname="Ad_Right" tagprefix="uc2" %>

<%@ MasterType VirtualPath="~/MemberUser/MemberMaster.Master" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.order_detail tr{ border-top:1px dotted #ccc;}
.order_detail tr td{ padding:5px;}
.order_detail tr:first-child{ border-top:none;}
</style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<!--wrapper start-->
<div id="wrapper">
	<!--left start-->
    <div class="shop_left">
        <uc1:MemberCategory ID="MemberCategory1" runat="server" />
    </div>
    <!--left end-->
    
    <!--centent start-->
    <div class="shop_centent">
    	<h2>我的订单</h2>
        <div class="box_order" id="div_orders">
            <div class="top">共<span id="span_order_count"><%=allOrderCount%></span> 个订单：           
             <a href="/MemberUser/MyOrder.aspx?type=unpaid">待付款</a>（<span><%=unpaidCount%></span>）
            <a href="/MemberUser/MyOrder.aspx?type=sended">已发货</a>（<span id="span_confirm_order"><%=sendedCount%></span>）
           <a href="/MemberUser/MyOrder.aspx?type=finished"> 已完成</a>（<span><%=finishedCountCount%></span>）</div>
          
<asp:Repeater ID="rpt_order" runat="server" onitemdatabound="rptOrder_ItemDataBound">
<ItemTemplate>
  <div class="orders" id='div_order<%# Eval("Id") %>'>
            	<div class="title">订单编号:<span><%#Eval("OrderNo") %></span>&nbsp;&nbsp;下单时间：<%# Eval("OrderTime") %> </div>
            	<div class="boss">
                <table width="100%" border="0">
                  <tr>
                    <th scope="col" class="order_detail">
                        <asp:Repeater ID="rpt_pro" runat="server">
                        <ItemTemplate>
                        <ul>
                            <li><a href='/product/ProductDetail.aspx?no=<%# Eval("ProductNo") %>' ><img src='<%# FileKit.FirstImgPathThumb(Eval("ThumbnailImage") as string) %>' width="80" height="70" /></a></li>
                            <li><div class="detail_text"><a href='/product/ProductDetail.aspx?no=<%# Eval("ProductNo") %>' ><%# Eval("ProductName") %></a></div><div class="detail_tex"> <%# GetSkuItemHtml(Eval("SkuProductNo") as string)%> <div class="detail_tex"><%# Eval("Remark") == null ? "" : "(" + printConfigStr(Eval("Remark") as string)+ ")"%></div></div></li>
                              
                            <li class="nu"><%# Eval("SalePrice")%></li>
                            <li class="num"><%# Eval("Quantity")%></li>
                            <div class="clear"></div>
                        </ul>
                        </ItemTemplate>
                        </asp:Repeater>
                    </th>
                    <th scope="col" class="money"><p>合计：￥<%# string.Format("{0:0.##}",Eval("TotalPrice") )%></p><p><%# GetPaymentName(Eval("PaymentType") as string )%></p></th>
                    <th scope="col" class="zhuangtai" >
                 <p>    [<%# ParamKit.GetValue("OrderIsConfirmed", Eval("IsConfirmed"), "&nbsp;")%>]<br />
				    [<%# ParamKit.GetValue("OrderPayStatus", Eval("PayStatus"), "&nbsp;")%>]<br />
				    [<%# ParamKit.GetValue("OrderShippingStatus", Eval("ShippingStatus"), "&nbsp;")%>]</p></th>
                    <th scope="col" class="another"><p>
                    <a href='/MemberUser/ViewOrder.aspx?orderno=<%# Eval("OrderNo") %>'>查看</a>
                    <%# (Eval("IsConfirmed") as string == "1" && Eval("IsFinished") as string == "1") ? "<a href='javascript:void(0);'   onclick='DelOrder(this,\"" + Eval("OrderNo") + "\")'  >删除</a>" : ""%> 
                     </p>
                    <p class="button">
                       <%#(Eval("IsCancelled") as string == "0" && Eval("IsConfirmed") as string == "0" && Eval("PayStatus") as string == "1") ? "<a href='javascript:void(0);'   onclick='ConfirmOrder(this)' orderno='" + Eval("OrderNo") + "' >确认收货</a>" : ""%> 

                    <%#(Eval("PaymentType") as string != "4" && Eval("PaymentType") as string != "2" && Eval("IsCancelled") as string == "0" && Eval("IsConfirmed") as string == "0" && Eval("PayStatus") as string == "0") ? "<a href='/paychannal/jump2paypage.aspx?o=" + Eval("OrderNo") + "'  >支付</a>" : ""%>    
                    </p>
                    <p><%# (Eval("IsConfirmed") as string == "0" && Eval("IsCancelled") as string == "0" && Eval("ShippingStatus") as string == "0" && Eval("PayStatus") as string == "0") ? "<a href='javascript:void(0);' onclick='CancelOrder(this,\""+Eval("OrderNo")+"\")' >取消订单</a>" : ""%>
                    </p>
                    </th>
                  </tr>
                </table>
            </div>
            </div>
</ItemTemplate>
                </asp:Repeater>
        </div>
    </div>
    <!--centent end-->
    
    <!--right start-->
    <div class="shop_right">
        <uc2:Ad_Right ID="Ad_Right1" runat="server" />
    </div>
    <!--right end-->
    
    <div class="clear"></div>
</div>
<!--wrapper end-->
<script type="text/javascript">
    function DelOrder(ct, orderno) {
        //删除订单
        if (confirm("您确认要删除这个订单吗？")) {
            $("#div_orders").ExecuteCommand({
                successCallBack: function (result) {
                    alert("删除成功");
                    location.href = '/MemberUser/MyOrder.aspx?type=<%=Request["type"] %>'
                },
                errorCallback: function (errorCode, msg) {
                    alert(msg);
                }
            }, 'DeleteOrder', { OrderNo: orderno });
        }

    }
    function CancelOrder(ct, orderno) {
        //取消订单
        if (confirm("您确认要取消这个订单吗？")) {
            $(ct).ExecuteCommand({
                successCallBack: function (result) {
                    //     $(ct).remove();
                    alert("取消成功");
                    location.href='/MemberUser/MyOrder.aspx?type=<%=Request["type"] %>'
                },
                errorCallback: function (errorCode, msg) {
                    alert(msg);
                }
            }, 'CancelOrder', { OrderNo:  orderno });
        }

    }

    function ConfirmOrder(ct) {
        $(ct).ExecuteCommand({
            successCallBack: function (result) {
                alert("确认收货成功");
                location.href = '/MemberUser/MyOrder.aspx?type=<%=Request["type"] %>'
            },
            errorCallback: function (errorCode, msg) {
                alert(msg);
            }
        }, 'ConfirmReceived', { OrderNo: $(ct).attr("orderno") });
    }
    function PayOrder(ct) {

        $(ct).ExecuteCommand({
            successCallBack: function (result) {
                alert("支付成功");
                location.href = '/MemberUser/MyOrder.aspx?type=<%=Request["type"] %>'
            },
            errorCallback: function (errorCode, msg) {
                alert(msg);

            }
        }, 'PayOrder', { OrderNo: $(ct).attr("orderno"), TradeNo: $(ct).attr("tradeno") ,UserCode:'<%= CurrentMemberAccount %>' });
    }
</script>
</asp:Content>
